package example.com.zcq.mymj.Adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import example.com.zcq.mymj.R;
import example.com.zcq.mymj.bean.CaiYiCai;

/**
 * @author zcq
 * @package example.com.zcq.mymj.Adapter
 * @fileName MyMj
 * @description: 这个类的描述
 * @org 融信通达科技有限公司
 * @email @163.com
 * @date 2018/11/23  16:45
 */
public class ContentAdapter extends RecyclerView.Adapter<ContentAdapter.viewHolder> {
    private List<CaiYiCai.ShowapiResBodyBean.PbBean.ContentlistBean> mContentlistBeanList;

    public ContentAdapter(List<CaiYiCai.ShowapiResBodyBean.PbBean.ContentlistBean> contentlistBeanList) {
        mContentlistBeanList = contentlistBeanList;
    }

    @NonNull
    @Override
    public viewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.caiyicai_item, viewGroup,false);
        viewHolder viewHolder = new viewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull viewHolder viewHolder, int i) {
        CaiYiCai.ShowapiResBodyBean.PbBean.ContentlistBean contentlistBean = mContentlistBeanList.get(i);
        viewHolder.tvWen.setText(contentlistBean.getTitle());
        viewHolder.tvDa.setText(contentlistBean.getAnswer());

    }

    @Override
    public int getItemCount() {
        return mContentlistBeanList.size();
    }

    static class viewHolder extends RecyclerView.ViewHolder {
        TextView tvWen;
        TextView tvDa;

        public viewHolder(@NonNull View itemView) {
            super(itemView);
             tvWen = itemView.findViewById(R.id.tv_wen);
            tvDa = itemView.findViewById(R.id.tv_da);

        }
    }
}
